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

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: B = None
        self.r: B = None
        self.txt = txt

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

b = A("b")
j = B("j")
n = C("n")
f = D("f")

b.o = j
b.y = f
b.p = f
j.w = b
j.r = f
n.s = j
n.t = j
n.r = j
f.r = j
assert n.s.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: D = None
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: B = None
        self.r: B = None
        self.txt = txt

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

b = A("b")
j = B("j")
n = C("n")
f = D("f")

b.o = j
b.y = f
b.p = f
j.w = b
j.r = f
n.s = j
n.t = j
n.r = j
f.r = j
assert n.s.r.r.txt == "j"