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

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

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

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

m = A("m")
n = B("n")
l = C("l")
b = D("b")
k = B("k")
f = C("f")
c = D("c")

m.t = l
n.t = m
l.w = f
b.q = c
b.o = f
b.v = f
k.t = m
f.w = l
c.q = b
c.o = f
c.v = l
assert l.w.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

m = A("m")
n = B("n")
l = C("l")
b = D("b")
k = B("k")
f = C("f")
c = D("c")

m.t = l
n.t = m
l.w = f
b.q = c
b.o = f
b.v = f
k.t = m
f.w = l
c.q = b
c.o = f
c.v = l
assert l.w.w.w.w.w.w.w.txt == "f"