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

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

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

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

e = A("e")
h = B("h")
b = C("b")
k = D("k")
a = B("a")
g = D("g")
n = A("n")
d = B("d")
c = A("c")

e.q = n
h.p = g
h.t = g
b.u = g
b.v = k
k.x = g
k.y = b
k.q = b
a.p = g
a.t = g
g.x = k
g.y = b
g.q = b
n.q = e
d.p = k
d.t = k
c.q = e
assert k.x.x.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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

e = A("e")
h = B("h")
b = C("b")
k = D("k")
a = B("a")
g = D("g")
n = A("n")
d = B("d")
c = A("c")

e.q = n
h.p = g
h.t = g
b.u = g
b.v = k
k.x = g
k.y = b
k.q = b
a.p = g
a.t = g
g.x = k
g.y = b
g.q = b
n.q = e
d.p = k
d.t = k
c.q = e
assert k.x.x.x.y.txt == "b"