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

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: B = None
        self.txt = txt

b = A("b")
f = B("f")
h = C("h")
c = D("c")
a = D("a")

b.o = a
b.p = c
b.z = f
b.q = f
f.z = h
f.r = h
f.q = a
f.w = b
h.q = b
h.v = f
h.r = f
h.z = a
c.o = f
c.t = f
a.o = f
a.t = f
assert h.q.q.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.p: D = None
        self.z: B = None
        self.q: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: B = None
        self.txt = txt

b = A("b")
f = B("f")
h = C("h")
c = D("c")
a = D("a")

b.o = a
b.p = c
b.z = f
b.q = f
f.z = h
f.r = h
f.q = a
f.w = b
h.q = b
h.v = f
h.r = f
h.z = a
c.o = f
c.t = f
a.o = f
a.t = f
assert h.q.q.w.p.txt == "c"