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

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

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

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

g = A("g")
c = B("c")
d = C("d")
e = D("e")
f = C("f")
h = B("h")
a = D("a")
j = C("j")

g.v = h
c.y = g
d.u = j
d.p = c
d.r = g
d.o = h
e.p = a
e.w = g
f.u = d
f.p = h
f.o = h
f.r = g
h.y = g
a.p = e
a.w = g
j.u = d
j.p = h
j.r = g
j.o = c
assert e.w.v.y.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
d = C("d")
e = D("e")
f = C("f")
h = B("h")
a = D("a")
j = C("j")

g.v = h
c.y = g
d.u = j
d.p = c
d.r = g
d.o = h
e.p = a
e.w = g
f.u = d
f.p = h
f.o = h
f.r = g
h.y = g
a.p = e
a.w = g
j.u = d
j.p = h
j.r = g
j.o = c
assert e.w.v.y.v.y.v.txt == "h"