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

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: B = None
        self.x: A = None
        self.o: B = None
        self.txt = txt

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

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

f.r = m
b.y = c
g.y = f
g.x = f
g.p = b
g.o = b
e.w = f
e.y = f
e.q = c
e.s = g
m.y = f
m.x = f
m.p = b
m.o = b
c.w = f
c.y = f
c.q = e
c.s = m
assert c.y.r.y.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: B = None
        self.x: A = None
        self.o: B = None
        self.txt = txt

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

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

f.r = m
b.y = c
g.y = f
g.x = f
g.p = b
g.o = b
e.w = f
e.y = f
e.q = c
e.s = g
m.y = f
m.x = f
m.p = b
m.o = b
c.w = f
c.y = f
c.q = e
c.s = m
assert c.y.r.y.r.o.txt == "b"