class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: B = None
        self.o: B = None
        self.x: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: D = None
        self.txt = txt

j = A("j")
k = B("k")
h = C("h")
c = D("c")
d = B("d")
f = D("f")

j.u = h
k.x = h
k.q = d
h.u = j
h.w = d
h.x = d
h.o = k
c.x = j
c.s = f
d.x = h
d.q = k
f.x = j
f.s = c
assert j.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: B = None
        self.o: B = None
        self.x: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: D = None
        self.txt = txt

j = A("j")
k = B("k")
h = C("h")
c = D("c")
d = B("d")
f = D("f")

j.u = h
k.x = h
k.q = d
h.u = j
h.w = d
h.x = d
h.o = k
c.x = j
c.s = f
d.x = h
d.q = k
f.x = j
f.s = c
assert j.u.u.u.txt == "h"