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

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

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

class D:
    def __init__(self, txt: str):
        self.u: F = None
        self.w: A = None
        self.s: F = None
        self.p: F = None
        self.txt = txt

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

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

f = A("f")
h = B("h")
c = C("c")
b = D("b")
i = E("i")
a = F("a")

f.p = a
f.x = a
h.r = b
c.v = b
c.p = b
c.o = f
b.u = a
b.s = a
b.p = a
b.w = f
i.t = b
i.w = h
a.t = h
a.s = h
a.r = c
assert a.r.v.w.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.x: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: F = None
        self.w: A = None
        self.s: F = None
        self.p: F = None
        self.txt = txt

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

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

f = A("f")
h = B("h")
c = C("c")
b = D("b")
i = E("i")
a = F("a")

f.p = a
f.x = a
h.r = b
c.v = b
c.p = b
c.o = f
b.u = a
b.s = a
b.p = a
b.w = f
i.t = b
i.w = h
a.t = h
a.s = h
a.r = c
assert a.r.v.w.x.r.txt == "c"