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

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

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

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

d = A("d")
l = B("l")
g = C("g")
c = D("c")
j = B("j")
f = B("f")
e = D("e")

d.v = j
l.y = c
l.r = d
g.y = f
c.t = e
c.w = e
c.x = j
j.y = e
j.r = d
f.y = e
f.r = d
e.t = c
e.w = c
e.x = j
assert f.y.x.y.w.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

d = A("d")
l = B("l")
g = C("g")
c = D("c")
j = B("j")
f = B("f")
e = D("e")

d.v = j
l.y = c
l.r = d
g.y = f
c.t = e
c.w = e
c.x = j
j.y = e
j.r = d
f.y = e
f.r = d
e.t = c
e.w = c
e.x = j
assert f.y.x.y.w.x.r.txt == "d"