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

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

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

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

f = A("f")
e = B("e")
h = C("h")
j = D("j")
d = C("d")
g = B("g")
m = A("m")

f.u = m
f.x = d
e.t = g
e.x = g
h.r = m
h.v = g
j.x = g
j.p = f
j.v = f
d.r = m
d.v = e
g.t = e
g.x = e
m.u = f
m.x = h
assert d.v.t.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.x: C = None
        self.txt = txt

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

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

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

f = A("f")
e = B("e")
h = C("h")
j = D("j")
d = C("d")
g = B("g")
m = A("m")

f.u = m
f.x = d
e.t = g
e.x = g
h.r = m
h.v = g
j.x = g
j.p = f
j.v = f
d.r = m
d.v = e
g.t = e
g.x = e
m.u = f
m.x = h
assert d.v.t.x.x.txt == "g"