class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.o: D = None
        self.txt = txt

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

f = A("f")
m = B("m")
k = C("k")
j = D("j")
b = A("b")
e = C("e")
g = D("g")
h = D("h")

f.o = b
f.y = b
m.x = e
k.q = g
k.o = j
j.p = k
j.u = b
j.r = f
j.x = f
b.o = f
b.y = f
e.q = j
e.o = h
g.p = e
g.u = f
g.r = f
g.x = f
h.p = e
h.u = f
h.r = f
h.x = f
assert k.q.p.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.o: D = None
        self.txt = txt

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

f = A("f")
m = B("m")
k = C("k")
j = D("j")
b = A("b")
e = C("e")
g = D("g")
h = D("h")

f.o = b
f.y = b
m.x = e
k.q = g
k.o = j
j.p = k
j.u = b
j.r = f
j.x = f
b.o = f
b.y = f
e.q = j
e.o = h
g.p = e
g.u = f
g.r = f
g.x = f
h.p = e
h.u = f
h.r = f
h.x = f
assert k.q.p.q.u.txt == "b"