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

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

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

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

n = A("n")
j = B("j")
b = C("b")
f = D("f")
g = B("g")
e = C("e")
h = D("h")
a = A("a")

n.p = j
n.y = e
j.o = f
b.u = a
b.v = h
b.y = h
b.p = f
f.t = h
f.r = h
f.x = h
f.q = e
g.o = f
e.u = n
e.v = f
e.p = f
e.y = h
h.t = f
h.r = f
h.x = f
h.q = e
a.p = j
a.y = e
assert n.y.v.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: C = None
        self.txt = txt

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

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

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

n = A("n")
j = B("j")
b = C("b")
f = D("f")
g = B("g")
e = C("e")
h = D("h")
a = A("a")

n.p = j
n.y = e
j.o = f
b.u = a
b.v = h
b.y = h
b.p = f
f.t = h
f.r = h
f.x = h
f.q = e
g.o = f
e.u = n
e.v = f
e.p = f
e.y = h
h.t = f
h.r = f
h.x = f
h.q = e
a.p = j
a.y = e
assert n.y.v.x.t.t.txt == "h"