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

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

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

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

b = A("b")
j = B("j")
c = C("c")
g = D("g")
a = A("a")
e = A("e")

b.t = g
b.p = j
b.u = j
b.y = c
j.r = b
j.y = g
c.x = b
c.s = j
g.q = a
g.p = e
g.y = c
a.t = g
a.p = j
a.u = j
a.y = c
e.t = g
e.p = j
e.u = j
e.y = c
assert g.q.y.s.y.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: B = None
        self.u: B = None
        self.y: C = None
        self.txt = txt

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

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

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

b = A("b")
j = B("j")
c = C("c")
g = D("g")
a = A("a")
e = A("e")

b.t = g
b.p = j
b.u = j
b.y = c
j.r = b
j.y = g
c.x = b
c.s = j
g.q = a
g.p = e
g.y = c
a.t = g
a.p = j
a.u = j
a.y = c
e.t = g
e.p = j
e.u = j
e.y = c
assert g.q.y.s.y.p.u.txt == "j"