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

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: A = None
        self.p: C = None
        self.x: A = None
        self.txt = txt

g = A("g")
b = B("b")
l = C("l")
d = D("d")
k = A("k")
i = B("i")
j = D("j")
e = B("e")

g.y = j
g.t = l
b.q = i
b.t = i
b.u = j
l.y = k
d.r = j
d.y = k
d.p = l
d.x = g
k.y = d
k.t = l
i.q = e
i.u = j
i.t = b
j.r = d
j.y = g
j.p = l
j.x = k
e.q = b
e.t = b
e.u = j
assert g.y.r.y.y.y.t.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.t: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: A = None
        self.p: C = None
        self.x: A = None
        self.txt = txt

g = A("g")
b = B("b")
l = C("l")
d = D("d")
k = A("k")
i = B("i")
j = D("j")
e = B("e")

g.y = j
g.t = l
b.q = i
b.t = i
b.u = j
l.y = k
d.r = j
d.y = k
d.p = l
d.x = g
k.y = d
k.t = l
i.q = e
i.u = j
i.t = b
j.r = d
j.y = g
j.p = l
j.x = k
e.q = b
e.t = b
e.u = j
assert g.y.r.y.y.y.t.y.y.txt == "d"