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

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

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

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

f = A("f")
h = B("h")
a = C("a")
m = D("m")
l = C("l")

f.y = l
f.v = h
f.t = a
h.y = a
h.x = a
h.t = l
h.q = m
a.r = f
m.r = h
m.p = h
m.u = h
l.r = f
assert a.r.v.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.v: B = None
        self.t: C = None
        self.txt = txt

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

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

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

f = A("f")
h = B("h")
a = C("a")
m = D("m")
l = C("l")

f.y = l
f.v = h
f.t = a
h.y = a
h.x = a
h.t = l
h.q = m
a.r = f
m.r = h
m.p = h
m.u = h
l.r = f
assert a.r.v.q.u.txt == "h"