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

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

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

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

k = A("k")
n = B("n")
d = C("d")
f = D("f")
b = C("b")
g = A("g")
c = C("c")
i = C("i")
m = D("m")

k.y = g
n.r = f
d.u = g
f.q = m
f.v = m
f.r = n
f.o = d
b.u = k
g.y = k
c.u = g
i.u = g
m.q = f
m.v = f
m.r = n
m.o = i
assert i.u.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
d = C("d")
f = D("f")
b = C("b")
g = A("g")
c = C("c")
i = C("i")
m = D("m")

k.y = g
n.r = f
d.u = g
f.q = m
f.v = m
f.r = n
f.o = d
b.u = k
g.y = k
c.u = g
i.u = g
m.q = f
m.v = f
m.r = n
m.o = i
assert i.u.y.y.y.y.y.y.txt == "g"