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

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

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

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

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

b.p = m
b.q = e
b.w = f
e.w = m
e.q = m
e.s = b
m.s = b
f.q = l
f.v = m
l.w = m
l.q = m
l.s = b
assert b.p.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: B = None
        self.w: D = None
        self.txt = txt

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

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

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

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

b.p = m
b.q = e
b.w = f
e.w = m
e.q = m
e.s = b
m.s = b
f.q = l
f.v = m
l.w = m
l.q = m
l.s = b
assert b.p.s.q.txt == "e"