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

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

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

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

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

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

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

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

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

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

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