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

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

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

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

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

f.r = k
l.x = i
l.r = i
l.v = h
l.p = k
h.y = l
h.w = l
h.t = m
h.o = i
i.u = m
i.z = m
m.y = l
m.t = h
m.w = k
m.o = i
k.x = i
k.r = i
k.v = h
k.p = l
assert i.u.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

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

f.r = k
l.x = i
l.r = i
l.v = h
l.p = k
h.y = l
h.w = l
h.t = m
h.o = i
i.u = m
i.z = m
m.y = l
m.t = h
m.w = k
m.o = i
k.x = i
k.r = i
k.v = h
k.p = l
assert i.u.t.w.txt == "l"