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

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

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

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

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

d = A("d")
a = B("a")
g = C("g")
h = D("h")
j = E("j")

d.y = a
d.t = h
a.q = h
a.y = j
g.s = a
g.p = j
g.o = j
g.y = h
h.x = a
j.u = g
j.t = g
j.p = a
assert d.y.y.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.t: D = None
        self.txt = txt

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

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

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

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

d = A("d")
a = B("a")
g = C("g")
h = D("h")
j = E("j")

d.y = a
d.t = h
a.q = h
a.y = j
g.s = a
g.p = j
g.o = j
g.y = h
h.x = a
j.u = g
j.t = g
j.p = a
assert d.y.y.p.q.txt == "h"