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

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

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

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

b = A("b")
f = B("f")
h = C("h")
g = D("g")
k = D("k")
i = B("i")

b.t = i
f.q = i
h.r = g
g.o = h
g.u = b
g.y = b
g.t = i
k.o = h
k.u = b
k.y = b
k.t = i
i.q = f
assert h.r.t.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

b = A("b")
f = B("f")
h = C("h")
g = D("g")
k = D("k")
i = B("i")

b.t = i
f.q = i
h.r = g
g.o = h
g.u = b
g.y = b
g.t = i
k.o = h
k.u = b
k.y = b
k.t = i
i.q = f
assert h.r.t.q.q.q.txt == "f"