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

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

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

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

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

k = A("k")
j = B("j")
l = C("l")
n = D("n")
a = E("a")
d = D("d")
g = B("g")

k.y = g
k.r = a
k.o = l
k.p = l
j.t = n
l.w = d
n.v = d
a.r = k
a.q = g
d.v = n
g.t = d
assert g.t.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.r: E = None
        self.o: C = None
        self.p: C = None
        self.txt = txt

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

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

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

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

k = A("k")
j = B("j")
l = C("l")
n = D("n")
a = E("a")
d = D("d")
g = B("g")

k.y = g
k.r = a
k.o = l
k.p = l
j.t = n
l.w = d
n.v = d
a.r = k
a.q = g
d.v = n
g.t = d
assert g.t.v.v.v.v.v.v.txt == "d"