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

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.s: C = None
        self.r: C = None
        self.o: C = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: A = None
        self.txt = txt

b = A("b")
m = B("m")
f = C("f")
n = D("n")
e = A("e")
l = A("l")
h = C("h")

b.q = h
b.r = m
m.z = b
f.x = h
f.s = h
f.r = h
f.o = h
n.p = m
n.q = e
e.q = h
e.r = m
l.q = f
l.r = m
h.x = f
h.s = f
h.r = f
h.o = f
assert e.r.z.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.s: C = None
        self.r: C = None
        self.o: C = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: A = None
        self.txt = txt

b = A("b")
m = B("m")
f = C("f")
n = D("n")
e = A("e")
l = A("l")
h = C("h")

b.q = h
b.r = m
m.z = b
f.x = h
f.s = h
f.r = h
f.o = h
n.p = m
n.q = e
e.q = h
e.r = m
l.q = f
l.r = m
h.x = f
h.s = f
h.r = f
h.o = f
assert e.r.z.q.x.txt == "f"