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

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

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

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

g = A("g")
b = B("b")
c = C("c")
f = D("f")
j = B("j")
a = B("a")
l = A("l")
e = A("e")
i = D("i")

g.r = f
b.w = a
b.x = c
c.p = i
f.s = i
f.w = c
f.v = c
j.w = b
j.x = c
a.w = b
a.x = c
l.r = i
e.r = f
i.s = f
i.w = c
i.v = c
assert l.r.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

g = A("g")
b = B("b")
c = C("c")
f = D("f")
j = B("j")
a = B("a")
l = A("l")
e = A("e")
i = D("i")

g.r = f
b.w = a
b.x = c
c.p = i
f.s = i
f.w = c
f.v = c
j.w = b
j.x = c
a.w = b
a.x = c
l.r = i
e.r = f
i.s = f
i.w = c
i.v = c
assert l.r.v.p.txt == "i"