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

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

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

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

g = A("g")
k = B("k")
m = C("m")
d = D("d")
n = D("n")
h = B("h")
l = A("l")

g.q = d
g.o = n
g.s = l
k.u = h
m.w = g
m.r = h
d.t = k
n.t = k
h.u = k
l.q = d
l.o = d
l.s = g
assert h.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.o: D = None
        self.s: A = None
        self.txt = txt

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

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

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

g = A("g")
k = B("k")
m = C("m")
d = D("d")
n = D("n")
h = B("h")
l = A("l")

g.q = d
g.o = n
g.s = l
k.u = h
m.w = g
m.r = h
d.t = k
n.t = k
h.u = k
l.q = d
l.o = d
l.s = g
assert h.u.u.u.u.u.u.u.txt == "k"