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

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

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

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

e = A("e")
h = B("h")
j = C("j")
g = D("g")
l = C("l")
n = D("n")
b = B("b")
c = A("c")

e.v = n
e.p = j
e.u = c
h.x = g
j.q = e
j.y = b
g.u = e
l.q = e
l.y = h
n.u = e
b.x = n
c.v = g
c.p = j
c.u = e
assert b.x.u.p.y.x.u.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.p: C = None
        self.u: A = None
        self.txt = txt

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

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

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

e = A("e")
h = B("h")
j = C("j")
g = D("g")
l = C("l")
n = D("n")
b = B("b")
c = A("c")

e.v = n
e.p = j
e.u = c
h.x = g
j.q = e
j.y = b
g.u = e
l.q = e
l.y = h
n.u = e
b.x = n
c.v = g
c.p = j
c.u = e
assert b.x.u.p.y.x.u.u.v.txt == "g"