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

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

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

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

g = A("g")
k = B("k")
j = C("j")
b = D("b")
d = C("d")
h = A("h")
c = A("c")
m = C("m")
f = A("f")
e = B("e")

g.x = c
k.o = j
k.v = m
k.p = e
k.r = h
j.q = d
j.t = d
j.o = b
j.v = c
b.w = d
d.q = j
d.t = j
d.o = b
d.v = c
h.x = g
c.x = f
m.q = d
m.o = b
m.t = j
m.v = g
f.x = g
e.o = d
e.v = j
e.p = k
e.r = g
assert c.x.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

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

g = A("g")
k = B("k")
j = C("j")
b = D("b")
d = C("d")
h = A("h")
c = A("c")
m = C("m")
f = A("f")
e = B("e")

g.x = c
k.o = j
k.v = m
k.p = e
k.r = h
j.q = d
j.t = d
j.o = b
j.v = c
b.w = d
d.q = j
d.t = j
d.o = b
d.v = c
h.x = g
c.x = f
m.q = d
m.o = b
m.t = j
m.v = g
f.x = g
e.o = d
e.v = j
e.p = k
e.r = g
assert c.x.x.x.x.x.x.x.x.txt == "g"