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

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

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

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

f = A("f")
b = B("b")
e = C("e")
n = D("n")
h = C("h")
l = B("l")

f.s = b
b.r = f
e.v = b
e.p = b
e.u = l
e.r = n
n.x = e
h.v = b
h.u = b
h.r = n
h.p = l
l.r = f
assert e.r.x.v.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

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

f = A("f")
b = B("b")
e = C("e")
n = D("n")
h = C("h")
l = B("l")

f.s = b
b.r = f
e.v = b
e.p = b
e.u = l
e.r = n
n.x = e
h.v = b
h.u = b
h.r = n
h.p = l
l.r = f
assert e.r.x.v.r.s.txt == "b"